home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Grab Bag
/
Shareware Grab Bag.iso
/
011
/
lastrun.arc
/
LASTRUN.ASM
next >
Wrap
Assembly Source File
|
1986-10-17
|
8KB
|
230 lines
page 60,132
;Copyright 1986 Arnold Bernard Krueger
; all rights reserved
; 1600 Prestwick
; Grosse Pointe Woods, MI, 48236
; 313-881-4829 (voice)
;program to check file specified for current date
; Usage is: LASTRUN filename.ext
; filename.ext must exist and be 4 bytes long
; initially, both words should be zeros
;if file is current, return errorlevel=0
;if file is in the past, return errorlevel=1, and update it
;if file is in the future, return errorlevel=2
;create argument file as follows:
; DEBUG filename.ext
; run DEBUG.COM . File shouldn't be found
; E 100 ;enter data into file
; 00 00 00 00 ;make first four bytes zero
; RCX ;set length
; 4 ;to be four
; W ;write file out
; Q ;and quit
; LASTRUN filename.ext ;make it current
code_seg segment
assume cs:code_seg
assume ds:code_seg
assume es:code_seg
org 80h
parmlistl db 0 ;parameter list length from DOS
parmlist db 0 ;parameter list from DOS
org 0b0h
handle dw 0 ;file handle for I/O
asciiz db 0 ;work area carved out of parm area
org 100h
first:
code proc far
JMP start ;branch past data
db 'Copyright 1986, Arnold b. Krueger'
cr equ 0dh
lf equ 0ah
msgtxt1 db cr,lf,'Usage is: LASTRUN filespec -to check date file',cr,lf,'$'
msgtxt2 db 'Argument File not found',cr,lf,'$'
msgtxt3 db 'File open error',cr,lf,'$'
msgtxt4 db 'File read error',cr,lf,'$'
msgtxt5 db 'Time error',cr,lf,'$'
msgtxt6 db 'File point error',cr,lf,'$'
msgtxt7 db 'File write error',cr,lf,'$'
msgtxt8 db 'File close error',cr,lf,'$'
msglist dw msgtxt1-code_seg
dw msgtxt2-code_seg
dw msgtxt3-code_seg
dw msgtxt4-code_seg
dw msgtxt5-code_seg
dw msgtxt6-code_seg
dw msgtxt7-code_seg
dw msgtxt8-code_seg
date_rec dw 0,0 ;date from file 0YYY MMDD
date_now dw 0,0 ;current date 0YYY MMDD
errmsg1:
MOV AL,10h
JMP exitmsg
errmsg2:
MOV AL,11h
JMP exitmsg
errmsg3:
MOV AL,12h
JMP exitmsg
errmsg4:
MOV AL,13h
JMP exitmsg
errmsg5:
MOV AL,14h
JMP exitmsg
errmsg6:
MOV AL,15h
JMP exitmsg
errmsg7:
MOV AL,16h
JMP exitmsg
errmsg8:
MOV AL,17h
JMP exitmsg
start:
MOV SI,offset parmlistl ;point to parmlist length
MOV DI,offset asciiz ;point to AZCIIZ we build
XOR CX,CX ;clear CX
MOV CL,[SI] ;get length
INC SI
CMP CL,00h ;is length zero?
JNZ Charloop ;if not, check on
JMP errmsg1 ;otherwise, complain
Charloop:
LODSB
CMP AL,' ' ;strip off leading blanks
JBE Nextchar
CMP AL,'a' ;make file name upper case
JB Gotchar
CMP AL,'z'
JBE Casechar
JMP Gotchar
Casechar: AND Al,0ffh-20h ;make upper case
Gotchar: STOSB
Nextchar: LOOP Charloop
MOV BYTE PTR [DI],00h ;put fence on ASCIIZ
MOV DX,offset asciiz
CLC ;clear the carry flag
MOV AX,4E00h ;find first
MOV CX,0021h ;desired attributes
INT 21h
CMP AL,00h ;check success
JZ open
JMP errmsg2
open:
MOV DX,offset asciiz
MOV AX,3D02h ;open for read/write
INT 21h
JC errmsg3
MOV handle,AX ;save handle
MOV BX,handle ;get handle
MOV CX,4 ;get 4 bytes (yyyymmdd)
MOV DX,offset date_rec
MOV AH,3Fh ;read a record
INT 21h
JC errmsg4
MOV AH,2Ah ;get DOS date cx=yyy, dh=mm, dl=dd
INT 21h
JC errmsg5
MOV date_now,CX ;save yyy
MOV date_now+2,DX ;save mmdd
CMP CX,date_rec ;compare date_rec to current year
JZ check_day
JB future ;date_rec is in the future
JMP past
check_day:
CMP DX,date_rec+2 ;compare date_rec to current mmdd
JZ now
JB future ;date_rec is in the future
past:
MOV BX,handle ;get handle
XOR CX,CX ;offset is zero
XOR DX,DX
MOV AX,4200h ;set offset from start of file
INT 21h
JNC write
JMP errmsg6
write:
MOV BX,handle ;get handle
MOV CX,4 ;write 4 bytes (yyyymmdd)
MOV DX,offset date_now
MOV AH,40h ;write a record
INT 21h
MOV AL,1
JNC goodexit
JMP errmsg7
now: MOV AL,0 ;if file has current date
JMP goodexit ; then close it and exit
future: MOV AL,2 ;if file date > current date
JMP goodexit ; the clock might be broke
goodexit:
PUSH AX ;save errorlevel
MOV AX,handle
MOV AH,3Eh ;close file
INT 21h
POP AX ;restore errorlevel
JNC exit ;if no errors, exit
JMP errmsg8
exitmsg:
PUSH AX ;save errorlevel
SUB AX,10h ;reduce to offset
SHL AX,1 ;multiply by 2 to get words
ADD AX,offset msglist
MOV SI,AX ;get address of msg address
MOV DX,[SI] ;get msg address
MOV AH,09h ;send out some text
INT 21h
POP AX ;restore errorlevel
exit:
MOV AH,4Ch ;terminate process
INT 21h
code ENDP
code_seg ENDS
END first
┬ Uï∞ï^Çuâ t╕= PΦ╒ûïσ]┬ Uï∞ï^÷G@tï_Çu╕>